package com.hankol.newretail.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


import com.hankol.newretail.bean.MallTabBean;

import java.util.ArrayList;

/** tab适配器
 */
public class HomeMallTabPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> mFragments;
     public ArrayList<MallTabBean> mTitles=new ArrayList<>();

    public HomeMallTabPagerAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    public void setFragments(ArrayList<Fragment> mFragments, ArrayList<MallTabBean> mTitles) {
        this.mFragments = mFragments;
        this.mTitles = mTitles;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int i) {
        return mFragments.get(i);
    }

    @Override
    public int getCount() {
        return mTitles.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position).getName();
    }
}
